This invention relates generally to the field of distributed computing and more particularly relates to facilitating access to and use of reusable software components, such as Enterprise JavaBeans (EJB) components.
Like everything else, computer use has changed over the years. In the early days, large mainframe computers dominated the industry until the advent of the personal stand-alone computer and now many businesses and homes have at least one personal stand-alone computer. A new paradigm of computing, however, is emerging: one of distributed computing in which at least two, but more likely many more computers, called clients and servers, are interconnected to through a network wherein the logic and the software applications used by one client or server resides on another server. Thus, a server provides the application software, the logic, and sometimes even the databases for a number of other servers and clients.
The explosive growth of access to the World Wide Web, moreover, has further changed the paradigm of computing such that in today""s computing environment, the network connecting clients and servers is the World Wide Web. JAVA(trademark) is a programming language developed by Sun Microsystems, Inc. that has blossomed and thrived in the mid to late 1990s coincident with the burgeoning expansion of network computer technology and browser technology on the Internet, in part because Java is independent of the operating system of a computer. Java applications can be written on one computer and transferred over a network, such as the Internet, to any processing device having a Java virtual machine regardless of the hardware or software in the receiving machine, consistent with the xe2x80x9cWrite Once, Run Anywherexe2x80x9d philosophy of Java software development. Thus, Java applications can be written on one server and then transferred over the Web to multiple clients/servers. In fact, this model of computing is the basis of the Enterprise JavaBeans(trademark) technology developed by Sun Microsystems, Inc. and other software developers who write development tools.
A tutorial in definitions as used herein may be helpful. An application or a client program is a software program used by an end user. For instance, a person entering data to schedule employees"" work days may be using a scheduling client program or application. A person writing a paper may be using a word processing application. A person creating a visual demonstration may be using a presentation application. A tool is a software application environment that enables a software developer to write further applications in a particular computer environment IBM Corporation""s VisualAge(copyright) for Java and Microsoft Corporation""s Visual J++(copyright) are examples of tools that allow a programmer to write Java applications. A component is software code that can be reused across multiple applications; in other words, a component is standard software that can be pulled off a server and incorporated into new applications using a tool by software developers. For example, a calendar component may be used in several applications such as a scheduling application, a presentation application, a database application to calculate employee""s vacation and pay, etc. Thus, a software developer using tools to write an application can pull a calendar component off the server for insertion into the application.
A Java bean is a particular kind of component that can be visually manipulated in a tool and is designed according to a standard protocol of Sun Microsystems for the Java programming language, namely the JavaBeans specification. An enterprise bean is a reusable development component in a client/server environment that is designed according to Sun Microsystems"" Enterprise JavaBeans specification, a programming model for server side components in Java with support for transactions and security. Enterprise beans are intended to be relatively coarse-grained business objects such as a generic purchase order or an employee record or a calendar. Preferably, Java beans and enterprise beans conform to their respective Sun specifications. However, it should be apparent to those skilled in the art that enterprise beans, Java beans or any other components defined according to a Sun specification herein need not fully conform to those specifications but rather may meet only some of the specification requirements.
An enterprise bean is defined by two interfaces: (1) the public or home interface containing methods to either create or remove enterprise beans and, in the case of persistent enterprise beans (entity beans), to find and instantiate an enterprise bean; and (2) the remote interface or EJBObject which defines the business methods of an enterprise bean that can be accessed by a client program. Any interface of a Java bean is defined by three aspects: (1) attributes; (2) events; and (3) methods. An attribute is supported by public getter and/or setter methods. Attributes of the class must be exposed to the developer by the remote interface according to the JavaBeans protocol of the specification and have a naming convention for getter/setter methods to allow the tools and programmers to easily recognize and utilize the capabilities of Java beans defined according to the JavaBeans specification. Attributes may be of three kinds: simple; boolean; or indexed, each of which may be bound or constrained. An example of a simple attribute in a spreadsheet tool would be the balance of an account. An example of an indexed attribute in the spreadsheet tool would be the owners of an account, if there were more than one owner. An example of a boolean attribute would be if the balance of the account were greater or less than a particular amountxe2x80x94the response would be true or false. A bound attribute tells its dependent attributes that it has changed when/after it changes. A constrained attribute notifies its dependent attributes before it changes and the listeners of that constrained attribute have the option to veto the change, which is called an exception, i.e., the dependent attribute generates an exception to the proposed change. An example of a bound attribute would be the balance of a bank account. An example of a constrained attribute would be change of ownership of the account. A session object is an Enterprise JavaBeans object that executes on behalf of a single client, can be aware of transactions, can update shared data in an underlying database but does not represent directly shared data in the database, and is relatively short-lived. An entity object provides an object view of data in the database, allows shared access of data in the database from multiple users, and can be long-lived. Java beans are distributed across a computer network through a Java Archive (JAR) which is basically a zip file with a manifest file.
FIG. 1 illustrates a typical prior art method of a client program accessing an enterprise bean. In step 1, a client program 150 must first obtain a name service context for a name server 120. Using the name server context, then in step 2, the client program 150 looks up the home interface 132 of an enterprise bean 138 (of possibly a plurality of enterprise beans n) using the name server 120. In step 3, using the home interface 132, the client program 150 creates or finds an instance of the enterprise bean 138 on the Enterprise JavaBeans (EJB) server 130. In step 4, the enterprise bean 138 returns an Enterprise JavaBeans proxy object 134, i.e., the remote interface, representing the enterprise bean instance. The proxy object 134 may issue a remote call which can generate and throw an exception if the client program 150 wishes to access or change data in database 100.
While programming directly to a Java bean is simple and well-established, programming directly to Enterprise JavaBeans interfaces increases the complexity of a user program and creates significant performance problems thus requiring extra effort on the part of the software developer. Performance is affected with enterprise beans because each call to an Enterprise JavaBeans proxy object is a remote call. If the enterprise bean has a large number of attributes, each call for an attribute is a remote call via a corresponding get XXX( ) method in the remote interface which process requires considerable processing resources and time.
There is thus a need in the industry to reduce the complexity of accessing reusable software components, especially enterprise beans according to the Enterprise JavaBeans specification, and then to eliminate the complexity of processing and time for multiple remote calls for each attribute/feature of the enterprise beans.
One aspect of the invention may be considered a method of simplifying access to a software component, comprising the steps of choosing the software component from a first server on a computer network; choosing a wrapper for the software component; mapping a home interface method of the software component to a constructor of the wrapper, and calling a remote interface method which in turns calls a software component remote interface method. The method may further comprise choosing at least one attribute of the software component to cache; and may also further comprise choosing string conversion for at least one of those chosen attributes. In a preferred embodiment the software component is an enterprise bean according to the Enterprise JavaBeans specification. When the software component is an enterprise bean and the wrapper is an Access Bean, the home interface method of the software component is mapped to a null constructor of the Access Bean. The method may occur on a second server connected to the first server on a computer network. The computer network may be the Internet.
Choosing a wrapper for the software component requires selecting one from the group consisting of a Type 1 Access Bean, a Type 2 Access Bean, and a Type 3 Access Bean. When attributes are to be cached, then choosing a wrapper for the software component further comprises selecting a Type 2 Access Bean or a Type 3 Access Bean.
The invention may also be considered a method of consuming an enterprise bean from a client program, comprising the steps of instantiating an Access Bean by calling one of a plurality of constructors; and calling a first of a plurality of methods of the Access Bean to instantiate the enterprise bean and a corresponding method of the enterprise bean. The method may further comprise calling subsequent methods of the Access Bean methods to call corresponding methods of the enterprise bean.
Yet another aspect of the invention may be considered a computer system for accessing a software component, comprising: a first server having a CPU and a software component accessed through at least one home interface method and at least one remote interface method; a second server having a CPU and client program to access the software component on the first server through a computer network; a database used by the software component and the client program; and a client program access code to map at least one home interface method of the software component to a constructor in the client program access code and to map at least one remote interface method of the software component to methods of the client program access code. The first server and the second server may be the same server in which case the computer network is an internal bus. Alternatively, the first server, the second server, the database, and the client program may each be on a different server connected on a computer network.
The invention is also a computer readable medium encoded with a set of executable instructions to perform a method for accessing a software component, the method comprising locating a name server of a software component; choosing the software component from the name server; choosing a wrapper for the software component; mapping a home interface of the software component to a null constructor of the wrapper; and mapping a remote interface method to a software component remote interface method. The computer readable medium may further comprise creating a local cache having a plurality of selected attributes of the software component; and then optionally choosing string conversion for any or all of the selected attributes. The local cache may be indexed according to each instance of the software component. The software component may be an enterprise bean.
Yet another embodiment of the invention may be a computer readable medium encoded with a set of executable instructions to perform a method for consuming an enterprise bean on a computer network, the method comprising: instantiating an Access Bean by calling one of a plurality of constructors; calling a first of a plurality of methods of the Access Bean to instantiate an enterprise bean and a corresponding method of the enterprise bean; and calling subsequent methods of the Access Bean to call corresponding methods of the enterprise bean.
The invention is also an apparatus to access a software component, comprising: a first server having the software component; a second server having a means to access the software component; means to instantiate the access means by calling a first of a plurality of constructors; means to call a first method of the access means to instantiate the software component; and means to call at least one subsequent constructor of the access means which calls a corresponding method of the software component; means to call at least one subsequent method of the access means which calls a corresponding method of the software component. The apparatus may further comprise means to cache a plurality of attributes of the software component. The software component may be an enterprise bean and the caching means may be a CopyHelper of a Type 2 or a Type 3 Access Bean wherein the Access Bean maps a plurality of setter and getter methods in a remote interface of the software component to a plurality of local get/set methods of the Access Bean. The apparatus may also have a String conversion means for at least one of the attributes. The apparatus may also have a means to index the cached attributes according to an instance of the enterprise bean where more than one instance exists. The apparatus may also have a cache synchronizing means to issue a remote call to create or flush or refresh the cache to/from said enterprise bean.
The invention is also a method of accessing an enterprise bean from a client program by wrapping the enterprise bean in an Access Bean so that the enterprise bean is seen as a Java bean to the client program. A plurality of attributes of the enterprise bean may be cached in the Access Bean. The cache may be indexed for each instance of the enterprise bean.
The invention is also a program storage device readable by a machine, tangibly embodying a program of instructions executable by a machine to perform the method steps of the invention.
In summary, in a preferred embodiment, this invention attempts to hide the complexity of programming to an enterprise bean from various Java client programs by providing a simple Java bean wrapper, called an Access Bean, for enterprise beans. The Access Bean is, generated by a development tool and hides the home and remote interfaces from the client program. The home interface methods are mapped to standard JavaBeans constructors while the remote interface methods are mapped to standard JavaBeans methods. Tedious tasks such as name context lookup and managing the enterprise bean instances are contained in runtime classes from which the generated Access Bean extends.
The use of Access Beans significantly increases performance when using large persistent enterprise beans, also called entity beans, in which all or a subset of their attributes persist in a persistent storage such as a database. The Access Bean provides fast access to an enterprise bean because the Access Bean maintains a local cache of attributes from the enterprise bean which can be indexed for more than one instance of an enterprise bean.
These and other objects, features and advantages of the present invention will be further described and more readily apparent from a review of the detailed description and preferred embodiments which follow.